﻿using DevFramework.Entities.Concrete;
using FluentValidation;

namespace DevFramework.Business.ValidationRules.FluentValidation
{
    public class ProductValidator : AbstractValidator<Product>
    {
        public ProductValidator()
        {
            base.RuleFor(t => t.ProductName).NotEmpty();
            base.RuleFor(t => t.CategoryId).NotEmpty();
            RuleFor(t => t.QuantityPerUnit).NotEmpty().When(t => t.CategoryId == 1);
            RuleFor(t => t.UnitPrice).GreaterThanOrEqualTo(0);

        }
    }
}
